package com.itheima.service;

import com.itheima.api.SmsFlashPromotionSessionApi;
import com.itheima.pojo.SmsFlashPromotionSession;
import com.itheima.vo.SmsFlashPromotionSessionVo;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Hakuna Matata
 * @date 2022-10-13-10:29
 */
@Service
public class FlashSessionService {
    @DubboReference
    private SmsFlashPromotionSessionApi flashPromotionSessionApi;

    //添加场次
    public void sessionCreate(SmsFlashPromotionSession flashPromotionSession) {
        flashPromotionSessionApi.sessionCreate(flashPromotionSession);
    }

    //删除场次
    public void sessionDelete(Long id) {
        flashPromotionSessionApi.sessionDelete(id);
    }

    //获取全部场次
    public List<SmsFlashPromotionSession> sessionList() {
        return flashPromotionSessionApi.sessionList();
    }

    //获取全部可选场次及其数量
    public List<SmsFlashPromotionSessionVo> sessionSelectList(Long flashPromotionId) {
        //有没有flashPromotionId都行
        //List<SmsFlashPromotionSessionVo> list = flashPromotionSessionApi.sessionSelectList(flashPromotionId);
        return flashPromotionSessionApi.sessionSelectList(flashPromotionId);
    }

    //修改启用状态
    public void updateStatus(Long id, Integer status) {
        flashPromotionSessionApi.updateStatus(id, status);
    }

    //修改场次
    public void sessionUpdate(Integer id, SmsFlashPromotionSession flashPromotionSession) {
        flashPromotionSessionApi.sessionUpdate(id, flashPromotionSession);
    }

    //获取场次详情
    public SmsFlashPromotionSession findSessionById(Long id) {
        return flashPromotionSessionApi.findSessionById(id);
    }
}
